package question

var ans [][]int

func Permute(nums []int) [][]int {

	for i := 0; i < len(nums); i++ {
		srcSlice := []int{}
		copy(nums, srcSlice)
		param := []int{}
		temp(append(param, nums[i]), append(srcSlice[:i], srcSlice[i+1:]...))
	}

	return ans
}

func temp(param []int, nums []int) {
	if len(nums) == 0 {
		ans = append(ans, param)
		return
	}

	for i := 0; i < len(nums); i++ {
		srcSlice := []int{}
		copy(nums, srcSlice)
		temp(append(param, nums[i]), append(srcSlice[:i], srcSlice[i+1:]...))
	}
	return
}
